package com.fxc.api;

import com.fxc.entity.Employee;
import com.fxc.factory.MyFallBackFactory;
import com.fxc.util.ResultEntity;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;


// 注解表示当前接口和一个provider对应，
//  注解中Value属性指定要调用Provider属性
//  注解中FallbackFactory属性指定Provider不可用时提供备用方案的工厂类型
@FeignClient(value = "fxc-provider", fallbackFactory = MyFallBackFactory.class )
public interface EmployeeRemoteService {

    // 远程调用的接口方法
    // 要求@RequestMapping注解映射地址一致
    // 要求方法啊声明一致
    // 用来获取请求参数@RequestParam @PathVariable @RequestBody 不能省略两边一致
    @RequestMapping("/provider/get/employee")
    public Employee getEmployeeRemote();

    @RequestMapping("/provider/get/employee/by/id")
    public Employee getEmployeeById(@RequestParam("empId") Integer empId);

    @RequestMapping("/provider/save/emp")
    public Employee saveEmploy(@RequestBody Employee employee);

    @RequestMapping("/provider/list/remote")
    public List<Employee> getListEmpListRemote(@RequestParam("keyword") String keyword);

    @RequestMapping("/provider/get/emp/with/circuit/breaker")
    public ResultEntity<Employee> getEmpWithCircuitBreaker(@RequestParam("signal") String signal);


}
